# tag/serializers.py
from rest_framework import serializers
from .models import Tag

class TagSerializer(serializers.ModelSerializer):
    class Meta:
        model = Tag
        fields = ['index', 'tag_name']  # 指定你要序列化的字段


class TagSerializer_for_liu(serializers.ModelSerializer):
    name = serializers.CharField(source='index')  # 将 `index` 重命名为 `name`
    # value = serializers.CharField(source='tag_name')  # 将 `tag_name` 重命名为 `value`

    class Meta:
        model = Tag
        fields = ['name']  # 使用重命名后的字段

class TagSerializer_for_liu2(serializers.ModelSerializer):
    name = serializers.CharField(source='index')  # 将 `index` 重命名为 `name`
    value = serializers.CharField(source='tag_name')  # 将 `tag_name` 重命名为 `value`

    class Meta:
        model = Tag
        fields = ['name','value']  # 使用重命名后的字段